package user

import "time"

type CommonUserBind struct {
	//Uid
	Uid string `gorm:"primary_key"`
	//聚合用户id
	CommonUserDataUid string
	//用户id
	TenantUserUid string
	//公众号openid
	Openid string
	//小程序openid
	MpOpenid string
	//微信unionid
	Unionid string
	//创建时间
	CreatedTime time.Time `gorm:"default:CURRENT_TIMESTAMP"`
	//修改时间
	ModifiedTime time.Time `gorm:"default:CURRENT_TIMESTAMP"`
	//是否删除
	IsDeleted int32 `gorm:"default:0"`
}

func (p CommonUserBind) TableName() string {
	return "common_user_bind"
}

type CommonUserData struct {
	//主键
	Uid string `gorm:"primary_key"`
	//租户用户guid
	TenantUserUid string
	//租户用户id
	TenantUserId int64
	//手机号
	MobilePhone string
	//租户code
	TenantCode string
	//用户名
	UserName string
	//账号
	UserCode string
	//创建时间
	CreatedTime time.Time `gorm:"default:CURRENT_TIMESTAMP"`
	//修改时间
	ModifiedTime time.Time `gorm:"default:CURRENT_TIMESTAMP"`
	//是否删除
	IsDeleted int32 `gorm:"default:0"`
	//是否禁用
	IsDisable int32 `gorm:"default:0"`
	BuUid     string
	Password  string
}

func (p CommonUserData) TableName() string {
	return "common_user_data"
}

type CommonUserLoginRecord struct {
	//Uid
	Uid string `gorm:"primary_key"`
	//聚合用户id
	CommonUserDataUid string
	//用户id
	TenantUserUid string
	//登录token
	Token string
	//创建时间
	CreatedTime time.Time `gorm:"default:CURRENT_TIMESTAMP"`
	//修改时间
	ModifiedTime time.Time `gorm:"default:CURRENT_TIMESTAMP"`
	//是否删除
	IsDeleted int32
	//登录类型：1-主应用PC；2-线索雷达小程序
	LoginType int32
	//应用标志，用来区分登录来源（单点登录用）
	Appid string
}

func (p CommonUserLoginRecord) TableName() string {
	return "common_user_login_record"
}

type CommonUserApply struct {
	//id
	Id int64 `gorm:"primary_key"`
	//手机号
	Mobile string
	// 创建时间
	CreatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP"`
	// 创建人
	CreatedBy string
	// 更新时间
	UpdatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP"`
	// 更新人
	UpdatedBy string
	//创建时间
	IsDeleted int32
}

func (p CommonUserApply) TableName() string {
	return "common_user_apply"
}

// 用户权限表
type CommonUserActionRightInfos struct {
	//uid
	Uid string `gorm:"primary_key"`
	//方法编码
	FunctionCode string
	//行为编码
	ActionCode string
	//应用编码
	Application string
	//租户code
	TenantCode string
	//租户用户id
	TenantUserUid string
	//创建时间
	CreatedTime time.Time `gorm:"default:CURRENT_TIMESTAMP"`
	//修改时间
	ModifiedTime time.Time `gorm:"default:CURRENT_TIMESTAMP"`
}

func (p CommonUserActionRightInfos) TableName() string {
	return "common_user_action_right_infos"
}

// 用户角色关系
type CommonUserRoleRelation struct {
	//uid
	Uid string `gorm:"primary_key"`
	//全局用户id，common_user_data的uid
	CommonUserDataUid string
	//创建时间
	CreatedTime time.Time `gorm:"default:CURRENT_TIMESTAMP"`
	//修改时间
	ModifiedTime time.Time `gorm:"default:CURRENT_TIMESTAMP"`
	//暂时不知道是啥
	RefType int32 `gorm:"default:0"`
	//建模角色id MyStandardRoleId
	RoleUid string
	//租户code
	TenantCode string
	//租户用户id
	TenantUserUid string
}

func (p CommonUserRoleRelation) TableName() string {
	return "common_user_role_relation"
}
